<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>滚动位置</title>
		<style type="text/css">
			#d1{
				width: 20px;
				height: 5000px;
				background: black;
			}
		</style>
	</head>
	<body>
		<div id="d1"></div>
	</body>
	<script type="text/javascript">
		window.onscroll = function() {
			// 滚动区域高度
			var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
			console.log('滚动条位置：' + scrollTop);
		}
	</script>
</html>